import { ref } from 'vue'

import { deptApi } from '@/apis'

export function useDeptTree() {
  const deptTree = ref([] as ITreeNode[])
  const treeLoading = ref(false)

  async function getDeptTree() {
    treeLoading.value = true

    deptTree.value = await deptApi.getDeptTree()

    treeLoading.value = false
  }

  return {
    deptTree,
    treeLoading,
    getDeptTree
  }
}
